/**
 * 订单管理 交易订单
 */
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>善款管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true"  class="user-search">
      <el-form-item label="搜索：">
        <el-input size="small" v-model="searchname" placeholder="输入捐助人名字"></el-input>
      </el-form-item>
    
      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
      </el-form-item>
      <el-form-item>
        <!-- <el-button size="small" type="primary" icon="el-icon-search" @click="zdzhh()">指定账户发放</el-button> -->
      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
      <el-table-column align="center" type="index" width="60">
      </el-table-column>
      <el-table-column sortable prop="id" label="捐助单ID"  show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="donorId" label="捐助人ID"  show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="donorName" label="捐助人姓名"  show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="donationAmount" label="捐助金额"  show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="entryId" label="受助单ID"  show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="state" label="审核状态"  show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="stateM" label="发放状态"  show-overflow-tooltip>
      </el-table-column>
      <!-- <el-table-column sortable prop="reviewer" label="审核者" show-overflow-tooltip>
      </el-table-column> -->
      <el-table-column sortable prop="account" label="善款流入账户"  show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="createDate" label="创建时间" show-overflow-tooltip>
        <template slot-scope="scope">
          <div>{{scope.row.createDate|timestampToTime}}</div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" min-width="100">
        <template slot-scope="{ row }">
          <el-button size="mini" type="primary" @click="ff(row)">发放</el-button>
          <el-button size="mini" type="danger" @click="open(row)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
    <!-- 编辑界面 -->
    <el-dialog :title="title" :visible.sync="editFormVisible" width="50%" >
      <el-form label-width="120px" :model="newlist" >
        <el-row>
          <el-col :span="12">
            <el-form-item label="账户">
              <el-input size="small" v-model="newlist.account" auto-complete="off" placeholder="请输入账户" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">取消</el-button>
        <el-button size="small" @click="yes()">确认发放</el-button>
   
      </div>
    </el-dialog>

    <!-- 指定发送 -->
  </div>
</template>

<script>
import axios from 'axios';
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      searchname:"",
      list2:{},
      list1:{},
      loading: false, //是显示加载
      editFormVisible1: false, //控制编辑页面显示与隐藏

      editFormVisible: false, //控制编辑页面显示与隐藏
      title: '预览',
     
     newlist:{},
      editForm: {
        id: '',
        donorId: '',
        donorName: 1,
        donationAmount: '',
        entryId: '',
        createDate: '',
        state: '',
        stateM: '',
        reviewer: '',
        account: '',
        token: localStorage.getItem('logintoken')
      },
      formInline: {
        page: 1,
        limit: 10,
        machineNo: '',
        orderNo: '',
        transId: '',
        payType: 0,
        orderStatus: 0,
        token: localStorage.getItem('logintoken')
      },
      // 删除部门
    
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      }
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  /**
   * 数据发生改变
   */

  /**
   * 创建完毕
   */
  created() {
    this.getdata()
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    // 指定账户发放
  //   zdzhh(){
  //     // this.editFormVisible = true
  // },
  // yes() {
  //     //  this.list2.account =this.newlist.account
  // // let data = this.list2
  //    console.log(data,'add信息');
  //       let list = {...row}
  //       this.$confirm('是否发放?', '提示', {
  //         confirmButtonText: '确定',
  //         cancelButtonText: '取消',
  //         type: 'warning'
  //       }).then(() => {
         
  //         axios.post("http://47.106.193.50:8080/admin/upDFF",list).then(res =>{
  //           let  xx = res.data.code
  //           if (xx == "200") {
  //               this.$message({
  //           type: 'success',
  //           message: '成功!'
  //         })
  //         this.getdata()
  //         }
  //         else{
  //         this.$message({
  //           type: 'info',
  //           message: '已取消'
  //         });     
  //         this.getdata()

  //       ;
  //           }
  //         })
         
  //       })
  //     },
    // cotrl
    kj(row){
  this.list2 = {...row}
        this.editFormVisible = true
     
    },

    //发放
   ff(row) {
        let list = {...row}
        this.$confirm('是否发放?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
         
          axios.post("http://47.106.193.50:8080/admin/upDFF",list).then(res =>{
            let  xx = res.data.code
            if (xx == "200") {
                this.$message({
            type: 'success',
            message: '成功!'
          })
          this.getdata()
          }
          else{
          this.$message({
            type: 'info',
            message: '已取消'
          });     
          this.getdata()

        ;
            }
          })
         
        })
      },
    //审核
     open(row) {
        let list = {...row}
        this.$confirm('是否审核通过?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
         
          axios.post("http://47.106.193.50:8080/admin/updDSh",list).then(res =>{
            let  xx = res.data.code
            if (xx == "200") {
                this.$message({
            type: 'success',
            message: '成功!'
          })
          this.getdata()
          }
          else{
          this.$message({
            type: 'info',
            message: '已取消'
          });     
          this.getdata()

        ;
            }
          })
         
        })
      },
    // 获取公司列表
   getdata() {
      this.loading = false
      axios.get("http://47.106.193.50:8080/admin/donations").then(res => {
        
            let data = res.data.data
            this.listData = data
            // 分页赋值
            // this.pageparm.currentPage = this.formInline.page
            // this.pageparm.pageSize = this.formInline.limit
            // this.pageparm.total = res.count
        })
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage
      this.formInline.limit = parm.pageSize
      this.getdata(this.formInline)
    },
    // 搜索事件
     search() {
        let arr= []
        let list =  this.listData
       console.log(list,'323232');
       if (this.searchname == "") {
           this.getdata()
       }else{
        // console.log(this.searchname);
        for (let i = 0; i < list.length; i++) {
         if (list[i].donorName.indexOf(this.searchname) >= 0) {
         arr.push(list[i])
      }}
        //  console.log(arr,'react');
         this.listData = arr
       }},
  

  
    // 关闭编辑、增加弹出框
    closeDialog() {
      this.editFormVisible = false
   
    },
     closeDialog1() {
      this.editFormVisible1 = false
   
    }
  }
}
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>

 
 

 